using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.Skill;

namespace TrainingManagement.api.Models.BusinessLogic.Skill
{
    public class SkillCreateOperation : BusinessOperation<BusinessObjects.Skill, BusinessObjects.Skill>
    {
        readonly SkillInsertDataSource _skillInsert = new SkillInsertDataSource();

        public override BusinessObjects.Skill Run(BusinessObjects.Skill input)
        {
            if (_skillInsert.Execute(input))
            {
                return input;
            }

            throw new Exception("Skill was not saved.");
        }
    }
}